package cn.itsource.wechatTemplate;

import cn.hutool.http.HttpUtil;
import cn.itsource.config.WechatConfig;
import cn.itsource.pojo.domain.OpenIdResult;
import com.alibaba.fastjson.JSON;


public class WechatLoginTemplate {

    private WechatConfig wechatConfig;

    public WechatLoginTemplate(WechatConfig wechatConfig) {
        this.wechatConfig = wechatConfig;
    }

    public String OpenId(String code){
        String url = String.format(WechatConfig.wechatUrl, wechatConfig.getAppid(), wechatConfig.getSecret(),code);
        String date = HttpUtil.get(url);
        OpenIdResult openIdResult = JSON.parseObject(date, OpenIdResult.class);
        String openid = openIdResult.getOpenid();
        return openid;
    }

    //获取手机号
}
